home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Technology Seed / Mac Tech Seed May '96 / Mac Tech Seed May '96.toast / mac / Unity a3c3 / CD Extras / DOS Compatibility / APPLE_PC / APPLEDOS.MS_ / APPLEDOS.bin
Encoding:
Text File  |  1996-02-29  |  9.8 KB  |  367 lines

  1. '**************************************************************************
  2. '*                       Houdini Windows Setup Script
  3. '**************************************************************************
  4.  
  5. '$UNDEF DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME       = 100
  12. CONST ASKQUIT       = 200
  13. CONST DESTPATH      = 300
  14. CONST EXITFAILURE   = 400
  15. CONST EXITQUIT      = 600
  16. CONST EXITSUCCESS   = 700
  17. CONST OPTIONS       = 800
  18. CONST APPHELP       = 900
  19. CONST CUSTINST        = 6200
  20. CONST TOOBIG        = 6300
  21. CONST BADPATH        = 6400
  22.  
  23. ''following were taken from windows.h. &H means they're hex
  24. CONST WS_VISIBLE        =&H10000000
  25. CONST WS_BORDER            =&H00800000
  26. CONST WS_CLIPCHILDREN    =&H02000000
  27. CONST GWL_STYLE            =-16
  28. CONST SW_SHOWMAXIMIZED    =3
  29.  
  30. '**    Bitmap ID
  31. CONST LOGO = 1
  32.  
  33. '** Install Sets (correspond to check-boxes in install dialog)
  34.  
  35. CONST kInstallWinClip    = 1
  36. CONST kInstallDOSClip    = 2
  37. CONST kInstallMacShare    = 3
  38. CONST kInstallCDROM        = 4
  39.  
  40. '** Flags for StripFileAndAdd
  41.  
  42. CONST kNoBackupFlag        = 1
  43.  
  44. '** Destination Directory
  45.  
  46. GLOBAL gDest$            '' Destination directory
  47. GLOBAL gAltCfgDir$        '' Path to alternate configuration
  48. GLOBAL gAutoExec$        '' Path to AutoExec.bat file
  49. GLOBAL gConfigSys$        '' Path to Config.sys file
  50. GLOBAL gSysDrive$        '' Path of system disk
  51. GLOBAL gSysIni$            '' Path to System.Ini file
  52.  
  53. '** Dialog list symbol names
  54.  
  55. GLOBAL gCheckStates$
  56. GLOBAL gDriveText$
  57.  
  58. DECLARE SUB Install
  59. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  60.  
  61. DECLARE FUNCTION ShowWindow  LIB "user.exe" (hWnd%,iShow%) AS INTEGER
  62. DECLARE FUNCTION SetWindowLong LIB "user.exe" (hWnd%, offset%, style&) AS LONG
  63. DECLARE FUNCTION StripFileAndAdd LIB "mscuistf.dll" (szPath$, szStrip$, szAdd$, flags%) AS INTEGER
  64. DECLARE FUNCTION QuitAppByWindowClass LIB "mscuistf.dll" (szWinClass$) AS INTEGER
  65.  
  66. INIT:
  67.     CUIDLL$        = "mscuistf.dll"            ''Custom user interface dll
  68.     HELPPROC$    = "FHelpDlgProc"              ''Help dialog procedure
  69.     
  70.     '**    Expand the main setup window to full-screen size
  71.     
  72.     hWnd%=HwndFrame()
  73.     m&=SetWindowLong(hWnd%, GWL_STYLE,WS_VISIBLE+WS_BORDER+WS_CLIPCHILDREN)
  74.     n%=ShowWindow(hWnd%, SW_SHOWMAXIMIZED)
  75.     
  76.     '**    Set our logo bitmap and window title
  77.     
  78.     SetBitmap CUIDLL$, LOGO
  79.     SetTitle "DOS Compatibility Installer"
  80.     
  81.     '**    Read the .inf file
  82.     
  83.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  84.     IF szInf$ = "" THEN
  85.         szInf$ = GetSymbolValue("STF_CWDDIR") + "appleDOS.INF"
  86.     END IF
  87.     ReadInfFile szInf$
  88.     
  89.     '**    Setup some default paths
  90.     
  91.     gSysDrive$    = MID$(GetWindowsDir, 1, 1)
  92.     gDest$        = gSysDrive$ + ":\Apple"
  93.     gAltCfgDir$ = gSysDrive$ + ":\ALT_CFGS"
  94.     gAutoExec$    = gSysDrive$ + ":\AutoExec.bat"
  95.     gConfigSys$    = gSysDrive$ + ":\Config.sys"
  96.     gSysIni$    = MakePath(GetWindowsDir, "System.ini")
  97.  
  98.     '**    CustInst list symbols
  99.     
  100.     gCheckStates$ = "CheckItemsState"
  101.     gDriveText$   = "DriveStatusText"
  102.     FOR i% = 1 TO 4
  103.         AddListItem gCheckStates$, "ON"
  104.     NEXT i%
  105.     FOR i% = 1 TO 7
  106.         AddListItem gDriveText$, ""
  107.     NEXT i%
  108.  
  109.     '**    Put up the welcome dialog
  110.  
  111. WELCOME:
  112.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$)
  113.     IF sz$ = "CONTINUE" THEN
  114.         UIPop 1
  115.     ELSE
  116.         GOSUB ASKQUIT
  117.         GOTO WELCOME
  118.     END IF
  119.  
  120. CUSTINST:
  121.  
  122.     '** Setup the destination path
  123.     
  124.     IF LEN(gDest$) > 23 THEN
  125.         ReplaceListItem gDriveText$, 7, MID$(gDest$, 1, 23)+"..."
  126.     ELSE
  127.         ReplaceListItem gDriveText$, 7, gDest$
  128.     END IF
  129.  
  130.     '**    Put up our custom install screen
  131.     
  132.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  133.  
  134.     '**    Respond to custom install
  135.     
  136.     IF sz$ = "CONTINUE" THEN
  137.         UIPop 1
  138.         GOTO DoInstall
  139.     ELSEIF sz$ = "PATH" THEN
  140.         GOTO GETPATH
  141.     ELSEIF sz$ = "CHK1" THEN
  142.         GOTO CUSTINST
  143.     ELSEIF sz$ = "CHK2" THEN
  144.         GOTO CUSTINST
  145.     ELSEIF sz$ = "CHK3" THEN
  146.         GOTO CUSTINST
  147.     ELSEIF sz$ = "CHK4" THEN
  148.         GOTO CUSTINST
  149.     ELSEIF sz$ = "REACTIVATE" THEN
  150.          GOTO CUSTINST
  151.     ELSE
  152.         GOSUB ASKQUIT
  153.         GOTO CUSTINST
  154.     END IF
  155.  
  156. GETPATH:
  157.     SetSymbolValue "EditTextIn", gDest$
  158.     SetSymbolValue "EditFocus", "END"
  159. GETPATHL1:
  160.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  161.     gDest$ = GetSymbolValue("EditTextOut")
  162.  
  163.     IF sz$ = "CONTINUE" THEN
  164.         IF IsDirWritable(gDest$) = 0 THEN
  165.             GOSUB BADPATH
  166.             GOTO GETPATHL1
  167.         END IF
  168.         UIPop 1
  169.         GOTO CUSTINST
  170.     ELSEIF sz$ = "REACTIVATE" THEN
  171.         GOTO GETPATHL1
  172.     ELSEIF sz$ = "BACK" THEN
  173.         UIPop 1
  174.         GOTO WELCOME
  175.     ELSE
  176.         GOSUB ASKQUIT
  177.         GOTO GETPATH
  178.     END IF
  179.     
  180. DoInstall:
  181.  
  182.     '**    Install the software
  183.  
  184.     Install
  185.  
  186.     '**    Cleanup, handling errors
  187.     
  188. QUIT:
  189.     ON ERROR GOTO ERRQUIT
  190.  
  191.     IF ERR = 0 THEN
  192.         dlg% = EXITSUCCESS
  193.     ELSEIF ERR = STFQUIT THEN
  194.         dlg% = EXITQUIT
  195.     ELSE
  196.         dlg% = EXITFAILURE
  197.     END IF
  198. QUITL1:
  199.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  200.     IF sz$ = "REACTIVATE" THEN
  201.         GOTO QUITL1
  202.     END IF
  203.     UIPop 1
  204.  
  205.     END
  206.  
  207. ERRQUIT:
  208.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  209.     END
  210.  
  211.  
  212.  
  213. BADPATH:
  214.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  215.     IF sz$ = "REACTIVATE" THEN
  216.         GOTO BADPATH
  217.     END IF
  218.     UIPop 1
  219.     RETURN
  220.  
  221.  
  222.  
  223. ASKQUIT:
  224.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  225.  
  226.     IF sz$ = "EXIT" THEN
  227.         UIPopAll
  228.         ERROR STFQUIT
  229.     ELSEIF sz$ = "REACTIVATE" THEN
  230.         GOTO ASKQUIT
  231.     ELSE
  232.         UIPop 1
  233.     END IF
  234.     RETURN
  235.  
  236.  
  237.  
  238. '**
  239. '** Purpose:
  240. '**     Builds the copy list and performs all installation operations.
  241. '** Arguments:
  242. '**     none.
  243. '** Returns:
  244. '**     none.
  245. '*************************************************************************
  246. SUB Install STATIC
  247.     autoExecFlags%    = 0
  248.     configSysFlags%    = 0
  249.     needTmp% = 0
  250.  
  251.     '**    Create the destination directory
  252.  
  253.     srcDir$ = GetSymbolValue("STF_SRCDIR")
  254.     CreateDir gDest$, cmoVital
  255.     CreateDir gAltCfgDir$, cmoVital
  256.     
  257.     '** Send a quit message to WinClip
  258.     
  259.     IF QuitAppByWindowClass("ClipSrvrWClass") <> 0 THEN
  260.         '** Couldn't find the window: so... Do you care?
  261.        END IF
  262.     
  263.     '**    Copy the files
  264.     
  265.     AddSectionFilesToCopyList "APPLEDIR", srcDir$, gDest$
  266.     AddSectionFilesToCopyList "ALTCFGDIR", srcDir$, gAltCfgDir$
  267.     AddSectionFilesToCopyList "SYSTEMDIR", srcDir$, GetWindowsSysDir
  268.     CopyFilesInCopyList
  269.     
  270.     '** Add WinClip to the startup group
  271.     
  272.     IF GetListItem(gCheckStates$, kInstallWinClip) = "ON" THEN
  273.         needTmp% = 1
  274.         CreateProgmanGroup "Startup", "", cmoNone
  275.         CreateProgmanItem "Startup", "Clipboard Converter", MakePath(gDest$, "WinClip.exe"), "", cmoOverwrite
  276.         
  277.         IF StripFileAndAdd(gAutoExec$, "ApplePC", "LH " + MakePath(gDest$, "ApplePC"), autoExecFlags%) = 0 THEN
  278.             autoExecFlags% = kNoBackupFlag
  279.         END IF
  280.     END IF
  281.     
  282.     '** Add MacShare to AutoExec.bat
  283.     
  284.     IF GetListItem(gCheckStates$, kInstallMacShare) = "ON" THEN
  285.         IF StripFileAndAdd(gAutoExec$, "MacShare", "LH " + MakePath(gDest$, "MacShare"), autoExecFlags%) = 0 THEN
  286.             autoExecFlags% = kNoBackupFlag
  287.         END IF
  288.     END IF
  289.     
  290.     '** Add CDROM to AutoExec.bat & Config.sys
  291.     
  292.     IF GetListItem(gCheckStates$, kInstallCDROM) = "ON" THEN
  293.         IF StripFileAndAdd(gAutoExec$, "MSCDEX", "LH " + gSysDrive$ + ":\DOS\MSCDEX /D:CDDRVR /L:E", autoExecFlags%) = 0 THEN
  294.             autoExecFlags% = kNoBackupFlag
  295.         END IF
  296.         IF StripFileAndAdd(gConfigSys$, "CDROM", "DEVICE=" + MakePath(gDest$, "CDROM.SYS") + " /D:CDDRVR", configSysFlags%) = 0 THEN
  297.             configSysFlags% = kNoBackupFlag
  298.         END IF
  299.     END IF
  300.     
  301.     '** Add DOSClip to AutoExec.bat
  302.     
  303.     IF GetListItem(gCheckStates$, kInstallDOSClip) = "ON" THEN
  304.         needTmp% = 1
  305.         IF StripFileAndAdd(gAutoExec$, "DOSClip", "LH " + MakePath(gDest$, "DOSClip"), autoExecFlags%) = 0 THEN
  306.             autoExecFlags% = kNoBackupFlag
  307.         END IF
  308.     END IF
  309.     
  310.     '** Create the temp directory and tmp environment variable
  311.     '** if they're needed and they don't yet exist
  312.     
  313.     tmpDir$ = GetEnvVariableValue("tmp")
  314.     IF (tmpDir$ = "") OR (DoesDirExist(tmpDir$)=0) THEN
  315.     
  316.         '** Figure out what tmp should be
  317.         
  318.         tmpDir$ = gSysDrive$ + ":\Temp"
  319.         
  320.         '** Add it to the environment
  321.         
  322.         IF StripFileAndAdd(gAutoExec$, "tmp=", "set tmp=" + tmpDir$, autoExecFlags%) = 0 THEN
  323.             autoExecFlags% = kNoBackupFlag
  324.         END IF
  325.         
  326.         '** Create the directory
  327.         
  328.         CreateDir tmpDir$, cmoVital
  329.         
  330.     END IF
  331.     
  332.     '**    If there are system files that need to be updated,
  333.     '**    then restart the computer after informing the user.
  334.     
  335.     IF RestartListEmpty = 0 THEN
  336.         IF ExitExecRestart = 1 THEN
  337.             '** Hmmm. We failed!
  338.         END IF
  339.     END IF
  340.  
  341. END SUB
  342.  
  343.  
  344.  
  345. '**
  346. '** Purpose:
  347. '**     Appends a file name to the end of a directory path,
  348. '**     inserting a backslash character as needed.
  349. '** Arguments:
  350. '**     szDir$  - full directory path (with optional ending "\")
  351. '**     szFile$ - filename to append to directory
  352. '** Returns:
  353. '**     Resulting fully qualified path name.
  354. '*************************************************************************
  355. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  356.     IF szDir$ = "" THEN
  357.         MakePath = szFile$
  358.     ELSEIF szFile$ = "" THEN
  359.         MakePath = szDir$
  360.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  361.         MakePath = szDir$ + szFile$
  362.     ELSE
  363.         MakePath = szDir$ + "\" + szFile$
  364.     END IF
  365. END FUNCTION
  366.  
  367.